package com.example.demo.connerlt;


import org.graalvm.compiler.lir.CompositeValue;

import java.text.SimpleDateFormat;
import java.util.Date;
@Component
@EnableScheduling
public class AlarmTask {

    @Scheduled(crom = "0/5 * * * * *")
    public void run() throws InterruptedException{
        Thread.sleep( millis:6000);
        System.out.println(Thread.currentThread().getName()+"=====>使用时间"+(System.currentTimeMillis()/1000));


    }
    @Scheduled(fixedRate = 5000)
    public void run1() throws InterruptedException{
        Thread.sleep(millis:7000);
        System.out.println(Thread.currentThread().getName()+"=====>使用时间"+(System.currentTimeMillis()/1000));
    }

    private static final SimpleDateFormat format=new SimpleDateFormat(pattern:"HH:mm:ss");

    @Scheduled(fixedDelayString = "2000")
    public void run2() throws InterruptedException{
        Thread.sleep(5000);
        System.out.println("fixedDaleyString的时间为:"+format.format(new Date()));
    }
    @Scheduled(fixedRateString = "2000",intialDelay = 1000)
    public void run3() throws InterruptedException{
        Thread.sleep(5000);
        System.out.println("每隔2秒并且延时1秒，在执行:"+format.format(new Date()));
    }


}



}
